﻿#region Using directives

using System;
using System.Globalization;
using System.Resources;
using System.ComponentModel;

#endregion

namespace MCMLXVII.Tools.OrganizationChart.MembersClasses
{
    public class LocCategoryAttribute: CategoryAttribute 
    {
        public LocCategoryAttribute(string CategoryKey): base(CategoryKey)
        {

        }

        protected override string GetLocalizedString(string value)
        {
            ResourceManager rm = new ResourceManager(typeof(MCMLXVII.Tools.OrganizationChart.Properties.Resources));
            string cn = null;
            for (CultureInfo ci = CultureInfo.CurrentCulture; cn == null && ci != CultureInfo.InvariantCulture; ci = ci.Parent)
            {
                try
                {
                    cn = (string)rm.GetString(value, ci);
                }
                catch 
                {
                    cn = value + " !";
                }
            }
            return cn;
        }

    }
    public class LocDescriptionAttribute : DescriptionAttribute 
    {
        public LocDescriptionAttribute(string Description): base(Description)
        {

        }

        public override string Description
        {
            get
            {
                ResourceManager rm = new ResourceManager(typeof(MCMLXVII.Tools.OrganizationChart.Properties.Resources));
                string cn = null;
                for (CultureInfo ci = CultureInfo.CurrentCulture; cn == null && ci != CultureInfo.InvariantCulture; ci = ci.Parent)
                {
                    try
                    {
                        cn = (string)rm.GetString(base.Description, ci);
                    }
                    catch 
                    {
                        cn = base.Description + " !";
                    }

                }
                return cn;
            }
        }

    }
    public class LocDisplayNameAttribute : DisplayNameAttribute
    {
        public LocDisplayNameAttribute(string DisplayName): base(DisplayName)
        {

        }

        public override string DisplayName
        {
            get
            {
                ResourceManager rm = new ResourceManager(typeof(MCMLXVII.Tools.OrganizationChart.Properties.Resources));
                string cn = null;
                for (CultureInfo ci = CultureInfo.CurrentCulture; cn == null && ci != CultureInfo.InvariantCulture; ci = ci.Parent)
                {
                    try
                    {
                        cn = (string)rm.GetString(base.DisplayName, ci);
                    }
                    catch 
                    {
                        cn = base.DisplayName + " !";
                    }
                }
                return cn;
            }
        }

    }


}
